<?php
// Make sure an ID was passed
    if(isset($_GET['text_id'])) {
        // Get the ID$id
        $id = intval($_GET['text_id']);
        // Make sure the ID is in fact a valid ID
    if($id <= 0) {
        // if id is not found
        die('The ID is invalid!');
    }
    else {
        // Connect to the database
        $dbLink = new mysqli('localhost', 'root', "", 'db_name');
        if(mysqli_connect_errno()) {
            die("MySQL connection failed: ".mysqli_connect_error());
        }
        
         // get the file information
        $query = "
            DELETE
            FROM `texts`
            WHERE `text_id` = {$id}";
        $result = $dbLink->query($query);
          if($result) {
            echo "post deleted successfully";
            }
            else {
                echo 'error, post not found';
            }
            // Free the mysqli resources
    }
}
    
?>  
